home *** CD-ROM | disk | FTP | other *** search
/ CyberMycha 2008 January / Cybermycha 1_2008.iso / Data.cab / _B877D175CAD64E01B32A0E1798BB1279 < prev    next >
Encoding:
Text File  |  2004-07-16  |  939 b   |  41 lines

  1.  
  2. #define     _NV3x_
  3.  
  4. #ifdef _NV3x_
  5.     #define HALF half
  6.     #define HALF2 half2
  7.     #define HALF4 half4
  8.     #define HALF3 half3
  9.     #define HALF3x3 half3x3
  10. #else
  11.     #define HALF float
  12.     #define HALF2 float2
  13.     #define HALF4 float4
  14.     #define HALF3 float3
  15.     #define HALF3x3 float3x3
  16. #endif
  17.  
  18. HALF fresnel( HALF3 normal, float3 E, HALF powscale ) {
  19.     return    pow(1 - pow(dot(normal, E), 2), powscale);     // fresnel = 1 - (N dot E)^2
  20. }
  21.  
  22. HALF diffuse( HALF3 normal, float3 L) {
  23.     HALF result = saturate(dot( normal, L));
  24.     result *= saturate( L.z*8 );        //self shadowing
  25.     return result;
  26. }
  27.  
  28. HALF phong( float3 R, float3 L, HALF power) {
  29.     return pow(saturate(dot(R, L)), power);
  30. }
  31.  
  32. HALF blinn( float3 H, HALF3 normal, HALF power) {
  33.     return pow(saturate(dot(H, normal)), power);
  34.     // dodac self shadowing
  35. }
  36.  
  37. HALF luminance( HALF3 i ) {
  38.     return dot(i, HALF3( 0.13f, 0.23f, 0.33f));
  39. }    
  40.  
  41.